﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="input.aspx.cs" Inherits="AnyOffice.general.netmeeting.attend.input" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title></title>
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		
	</HEAD>
	<body class="bodycolor" topmargin="0" LEFTMARGIN="0" RIGHTMARGIN="0">
		<form id="Form1" method="post" runat="server">
			<table width="101%" border="0" cellspacing="1" class="small" cellpadding="3" bgcolor="#000000">
				<tr class="TableHeader">
					<td><span>对象
							<select name="selectOnlineUsers" id="selectOnlineUsers" class="SmallSelect">
								<option value="" selected>所有人</option>
							</select>
							悄悄话<input name="IsPrivate" type="checkbox" id="IsPrivate" value="checkbox"> 字色<select id="selectColor" name="selectColor" onChange="setColor();" class="smallselect">
								<option style="COLOR: #000000" value="#000000" selected>黑色</option>
								<option style="COLOR: #7ec0ee" value="#7EC0EE">淡蓝</option>
								<option style="COLOR: #0088ff" value="#0088FF">海蓝</option>
								<option style="COLOR: #0000ff" value="#0000FF">草蓝</option>
								<option style="COLOR: #000088" value="#000088">深蓝</option>
								<option style="COLOR: #8800ff" value="#8800FF">蓝紫</option>
								<option style="COLOR: #ab82ff" value="#AB82FF">紫色</option>
								<option style="COLOR: #ff88ff" value="#FF88FF">紫金</option>
								<option style="COLOR: #ff00ff" value="#FF00FF">红紫</option>
								<option style="COLOR: #ff0088" value="#FF0088">玫红</option>
								<option style="COLOR: #ff0000" value="#FF0000">大红</option>
								<option style="COLOR: #f4a460" value="#F4A460">棕色</option>
								<option style="COLOR: #cc9999" value="#CC9999">浅褐</option>
								<option style="COLOR: #888800" value="#888800">卡其</option>
								<option style="COLOR: #888888" value="#888888">铁灰</option>
								<option style="COLOR: #cccccc" value="#CCCCCC">古黑</option>
								<option style="COLOR: #90e090" value="#90E090">绿色</option>
								<option style="COLOR: #008800" value="#008800">橄榄</option>
								<option style="COLOR: #008888" value="#008888">灰蓝</option>
							</select>
							<SCRIPT>
var messageColor='black';

function setColor()
{
	var selectColor = document.getElementById('selectColor');
	messageColor=selectColor.value;
}
							</SCRIPT>
							自动滚动<INPUT id="chScroll" type="checkbox" CHECKED name="chScroll"> </span>						
					</td>
				</tr>
				<TR class="TableHeader">
					<TD height="30px"><input type="text" class="SmallInput" id="txtMsg" style="WIDTH: 70%" onKeyPress="return clickButton(event,'btnSend')"
							size="70"> <input id="btnSend" onClick="SendMessage();" type="button" value="发言" class="SmallButton">
												
					</TD>
				</TR>
			</table>
			<SCRIPT language="javascript">
//回车键发送消息
function clickButton(e, buttonid)
{ 
	var bt = document.getElementById(buttonid); 
	if (typeof bt == 'object')
		{ 
			if(navigator.appName.indexOf("Netscape")>(-1)){ 
			if (e.keyCode == 13)
			{ 
				bt.click(); 
				return false; 
			} 
		} 
	if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1))
		{ 
			if (event.keyCode == 13)
			{ 
				bt.click(); 
				return false; 
			} 
		} 
	}	 
} 

//-------------------------------------------------------------------------------	
function scrollToBottom (element) {
	if (document.all.chScroll.checked){
		element.scrollTop = element.scrollHeight;
	}	
}
			</SCRIPT>

			<SCRIPT language="javascript">
var timer_message = null;
var timer_user = null;

function GetMessage()
{	
	if(timer_message!=null)
		window.clearTimeout(timer_message);
		
	AnyOffice.general.netmeeting.attend.AjaxMethods.GetMessage(<%=ViewState["SessionId"]%>,CallBack_GetMessage);
	timer_message=setTimeout("GetMessage()",3000);
}

function formatDate(vDate, vFormat)
{
	try
	{
		var vDateString       = vDate.substring(11,16);   
		return vDateString;
    }
    catch(e)
    {
		return vDate;
    }
} 
function CallBack_GetMessage(res)
{
	var msg = "";
	if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1)
	{
		for(var i=0; i<res.value.Tables[0].Rows.length; i++)
		{
			msg = "";
			if(res.value.Tables[0].Rows[i].UserId == null)
			{
				if(res.value.Tables[0].Rows[i].Content == '@CLOSE')
				{
					alert("会议召集人已经结束会议！");
					parent.location='index.aspx';
				}
				else
				{
					msg = "[系统消息]：" + res.value.Tables[0].Rows[i].Content;
					msg += " <font color=#888888>["
					msg += formatDate(res.value.Tables[0].Rows[i].SendTime ,'hh/mm')
					msg += "]</font><br>";
					
					parent.chat_view.document.getElementById('msgContent').innerHTML += msg;
					//滚动消息内容
					scrollToBottom (parent.chat_view.document.getElementById('msgContent'));					
				}
			}
			else
			{
				msg = "<a href=\"javascript:parent.chat_input.SayTo('" + res.value.Tables[0].Rows[i].UserId + "');\">" + res.value.Tables[0].Rows[i].NickName + "</a>"
				
				if(res.value.Tables[0].Rows[i].ToId != null)
				{
					msg += "对";
					msg += "<a href=\"javascript:parent.chat_input.SayTo('" + res.value.Tables[0].Rows[i].ToId + "');\">" + res.value.Tables[0].Rows[i].ToNickName + "</a>"
				}
				if(res.value.Tables[0].Rows[i].IsPrivate == true)
					msg += "悄悄";
				msg += "说：";
				msg += "<font color=" + res.value.Tables[0].Rows[i].Color + ">" + res.value.Tables[0].Rows[i].Content + "</font>";
				msg += " <font color=#888888>["
				msg += formatDate(res.value.Tables[0].Rows[i].SendTime ,'hh/mm')
				msg += "]</font>";
				msg += "<br>";
				
				parent.chat_view.document.getElementById('msgContent').innerHTML += msg;
				//滚动消息内容
				scrollToBottom (parent.chat_view.document.getElementById('msgContent'));
			}		
		}
		
	}	
}

function GetUsers()
{
	if(timer_user!=null)
		window.clearTimeout(timer_user);
		
	AnyOffice.general.netmeeting.attend.AjaxMethods.GetOnline(<%=ViewState["SessionId"]%>,CallBack_GetUsers);
	timer_user=setTimeout("GetUsers()",30000);
}

function SayTo(userId)
{
	var oSelect = document.getElementById("selectOnlineUsers");
	for(var i=0;i<oSelect.length;i++)
	{
		if(oSelect.options[i].value == userId)
		{
			oSelect.options[i].selected = true;						
		}
	}

}

function CallBack_GetUsers(res)
{
	if(res != null && res.value != null && res.value.Tables != 0 && res.value.Tables.length == 1)
	{
		var selectValue="";
		var usersList="";
		var onlineNums=0;
		var opt;
		var oSelect = document.getElementById("selectOnlineUsers");		
		selectValue = oSelect.value;
		
		// clear dropdownlist
		for(var i=oSelect.length-1; i>0; i--)
		{
			oSelect.options[i] = null;
		}	
				
		for(var i=0; i<res.value.Tables[0].Rows.length; i++)
		{
			usersList += "<a href=\"javascript:parent.chat_input.SayTo('" + res.value.Tables[0].Rows[i].UserId + "');\">" + res.value.Tables[0].Rows[i].NickName + "</a><br>"
			opt = new Option(res.value.Tables[0].Rows[i].NickName, res.value.Tables[0].Rows[i].UserId);
			oSelect.options[oSelect.length] = opt;
			onlineNums +=1;		
		}
		
		var oOnlineNums = parent.chat_user.document.getElementById("onlineNums")
		if(oOnlineNums != null)
			oOnlineNums.innerHTML = "在线人员" + onlineNums + "人";
		
		var onlineUsersList = parent.chat_user.document.getElementById("onlineUsersList")
		if(onlineUsersList != null)
			onlineUsersList.innerHTML = usersList;	
				
		
		for(var i=0;i<oSelect.length;i++)
		{
			if(oSelect.options[i].value == selectValue)
			{
				oSelect.options[i].selected = true;						
			}
		}
		
	}	
}

function SendMessage()
{
	var color = messageColor;
	var content = document.getElementById('txtMsg').value;
	if(content == "")
		return;
	var oSelect = document.getElementById("selectOnlineUsers");		
	var toId = oSelect.value;
	
	var isPrivate = document.all.IsPrivate.checked;

	//输入框清空
	document.getElementById('txtMsg').value='';

	AnyOffice.general.netmeeting.attend.AjaxMethods.SendMessage(<%=ViewState["SessionId"]%>, toId, color, isPrivate, content);
}

GetMessage();
GetUsers();

			</SCRIPT>
		</form>
	</body>
</HTML>
